-- [[ uncomment it to disable this module ]]--
do return end

g_Port1 = Proto("testDissector", "testDissectorDescriptor")

print("Script testDissector")

-- define protocol fields


-- define dissector function (Tvb, Pinfo, TreeItem)
function g_Port1.dissector(buf, pkt, tree)
    print('which one called me?', pkt.proto_name)
    len=0;
    local pktlen = buf:reported_length_remaining()
    print(type(buf), buf, pktlen)
    print(type(tree), tree)

    print(type(pkt), pkt, pkt.proto_name)

    print(buf:range(0, 2))
    print(buf:range(2, 4))
    print(buf:range(-4, 4))
    -- print(buf:range(-4, 8))     -- error: out of bounds 
    print(buf:range(0, pktlen))

    print(buf(0, 2))
    print(buf(2, 4))
    print(buf(-4, 4))
    -- print(buf(-4, 8))           -- error: out of bounds 
    print(buf(0, pktlen))
end

print("Script testDissector exit")
